package com.zrwl.poscloud.core.restapi.proxy;


import com.alibaba.fastjson.JSON;
import com.zrwl.poscloud.commons.vo.proxy.UserInfoVO;
import com.zrwl.poscloud.xo.service.WeixinService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 */
@RestController
@RequestMapping("/weixin")
@Slf4j
public class WeixinRestApi {

    @Autowired
    private WeixinService weixinService;

    @RequestMapping("/getAccessToken")
    public String getAccessToken() {
        return weixinService.getAccessToken();
    }
    /**
     * getOpenId
     */
    @RequestMapping("/getOpenId")
    public String getOpenId(String code) {
        return JSON.toJSONString(weixinService.getOpenId(code));
    }

    /**
     * getUserInfo
     */
    @RequestMapping("/getUserInfo")
    public String getUserInfo(String openId,String accessToken) {
        UserInfoVO userInfo=weixinService.getUserInfo(openId,accessToken);
        return JSON.toJSONString(userInfo);
    }
}
